package com.cy1640.damai.bean;

import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chenyang on 2016/12/12.
 */

public class ParserJsonYanchu {
    public static List<Yanchu> parserJsonToList(String jsonString){
        try {
            List<Yanchu> list=new ArrayList<>();
            JSONObject obj=new JSONObject(jsonString);
            JSONArray jsonArray=obj.getJSONArray("l");
            Log.i("aaa","---json1--");
            for (int i = 0; i <jsonArray.length() ; i++) {
                JSONObject jsonObject=jsonArray.getJSONObject(i);
                Yanchu yanchu=new Yanchu();
                yanchu.setPriceName(jsonObject.getString("priceName"));
                yanchu.setI(jsonObject.getInt("i"));
                yanchu.setN(jsonObject.getString("n"));
                yanchu.setT(jsonObject.getString("t"));
//                yanchu.setSummary(jsonObject.getString("Summary"));
                yanchu.setVenName(jsonObject.getString("VenName"));
                list.add(yanchu);
//                String n=jsonObject.getString("n");
//                Log.i("aaa","-----"+n);
//                String t=jsonObject.getString("t");
//                String VenName=jsonObject.getString("VenName");
//                String priceName=jsonObject.getString("priceName");
//                String Summary=jsonObject.getString("Summary");
//                Log.i("aaa","-----"+Summary);
//                Yanchu bean=new Yanchu(priceName,t,VenName,Summary,n);
               // list.add(bean);
            }
            Log.i("aaa","--aaaa-->"+list);
            return list;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
